/*
  MCP2515.h - Library for Microchip MCP2515 CAN Controller
  
  Author: David Harding
  
  Created: 11/08/2010
  
  For further information see:
  
  http://ww1.microchip.com/downloads/en/DeviceDoc/21801e.pdf
  http://en.wikipedia.org/wiki/CAN_bus
*/

#ifndef MCP2515_h
#define MCP2515_h

//#include "WProgram.h"
#include "MCP2515_defs.h"


  
      // Constructor defining which pins to use for CS and INT
    //MCP2515(BYTE CS_Pin, BYTE INT_Pin);
      
      // Overloaded initialization function
      int Init_Simple(int baud, BYTE freq);
      int Init(int baud, BYTE freq, BYTE sjw);
      
      // Basic MCP2515 SPI Command Set
	void MCP_Reset();
	BYTE Read_Simple(BYTE address);
	void Read(BYTE address, BYTE data[], BYTE BYTEs);
      Frame ReadBuffer(BYTE buffer);
      void Write_Simple(BYTE address, BYTE data);
      void Write(BYTE address, BYTE data[], BYTE BYTEs);
      void LoadBuffer(BYTE buffer, Frame message);
      void SendBuffer(BYTE buffers);
      BYTE Status();
      BYTE RXStatus();
      void BitModify(BYTE address, BYTE mask, BYTE data);

      // Extra functions
      int MCP_Interrupt(); // Expose state of INT pin
      int Mode(BYTE mode); // Returns TRUE if mode change successful
	  
      int _init(int baud, BYTE freq, BYTE sjw, int autoBaud);
    // Pin variables
      
		
#endif



/*#ifndef MCP2515_h
#define MCP2515_h
#define BYTE unsigned char

/*
	SPIBUS clock 8
	SPIBUS out	10
	SPIBUS in	12
	CHIP_SELECT	4


typedef struct CanPacket
{
	unsigned int standarID;
	unsigned int extendedID;
	unsigned char numData;
	unsigned char data[8];
	
}CanPacket;

void MCPSendPacket(CanPacket packet);
int MCPReceivePacket(CanPacket *packet);

void SPIInit();
void MCPInit();
unsigned char MCPReadRegister(unsigned char adress);
BOOL Can_init(int CAN_Bus_Speed, BYTE Freq, BYTE SJW, BOOL autoBaud);
int AutoBaud(int CAN_Bus_Speed, BYTE Freq, BYTE SJW);
#endif


*/
